package com.cxlin.cwanandroid.model.api

import com.cxlin.base.model.bean.BaseResponse
import com.cxlin.cwanandroid.model.bean.ArticleList
import com.cxlin.cwanandroid.model.bean.Banner
import com.cxlin.cwanandroid.model.bean.Hot
import com.cxlin.cwanandroid.model.bean.Navigation
import com.cxlin.cwanandroid.model.bean.SystemParent
import com.cxlin.cwanandroid.model.bean.User
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

/**
 *
 * @Author: chenxunlin
 * @Date: 2024/4/26 14:47
 */
interface WanService {

    companion object {
        const val BASE_URL = "https://www.wanandroid.com"
    }

    @GET("/article/list/{page}/json")
    suspend fun getHomeArticles(@Path("page") page: Int): BaseResponse<ArticleList>

    @GET("/banner/json")
    suspend fun getBanner(): BaseResponse<List<Banner>>


    @FormUrlEncoded
    @POST("/user/login")
    suspend fun login(@Field("username") userName: String, @Field("password") passWord: String): BaseResponse<User>

    @GET("/user/logout/json")
    suspend fun logOut(): BaseResponse<Any>

    @FormUrlEncoded
    @POST("/user/register")
    suspend fun register(@Field("username") userName: String, @Field("password") passWord: String, @Field("repassword") rePassWord: String): BaseResponse<User>

    @GET("/lg/collect/list/{page}/json")
    suspend fun getCollectArticles(@Path("page") page: Int): BaseResponse<ArticleList>

    @POST("/lg/collect/{id}/json")
    suspend fun collectArticle(@Path("id") id: Int): BaseResponse<ArticleList>
    @POST("/lg/uncollect_originId/{id}/json")
    suspend fun cancelCollectArticle(@Path("id") id: Int): BaseResponse<ArticleList>

    @GET("/wxarticle/chapters/json")
    suspend fun getBlogType(): BaseResponse<List<SystemParent>>

    @GET("/user_article/list/{page}/json")
    suspend fun getSquareArticleList(@Path("page") page: Int): BaseResponse<ArticleList>

    @GET("/article/listproject/{page}/json")
    suspend fun getLastedProject(@Path("page") page: Int): BaseResponse<ArticleList>

    @GET("/project/tree/json")
    suspend fun getProjectType(): BaseResponse<List<SystemParent>>

    @GET("/tree/json")
    suspend fun getSystemType(): BaseResponse<List<SystemParent>>

    @GET("/article/list/{page}/json")
    suspend fun getSystemTypeDetail(@Path("page") page: Int, @Query("cid") cid: Int): BaseResponse<ArticleList>

    @GET("/navi/json")
    suspend fun getNavigation(): BaseResponse<List<Navigation>>


    @GET("/friend/json")
    suspend fun getWebsites(): BaseResponse<List<Hot>>

    @GET("/hotkey/json")
    suspend fun getHot(): BaseResponse<List<Hot>>

    @FormUrlEncoded
    @POST("/article/query/{page}/json")
    suspend fun searchHot(@Path("page") page: Int, @Field("k") key: String): BaseResponse<ArticleList>

    @GET("/project/list/{page}/json")
    suspend fun getProjectTypeDetail(@Path("page") page: Int, @Query("cid") cid: Int): BaseResponse<ArticleList>
}